﻿using J.FoodManageSet.Application.Command.BenchTableCommand;
using J.FoodManageSet.Application.Command.DishesCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace J.FoodManageSet.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DineController : ControllerBase
    {
        private readonly IMediator _mediator;

        public DineController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 堂食添加
        /// </summary>
        [HttpPost]
        public async Task<int> DineAddUpdate(DineAddCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 图片上传
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        [HttpPost]
       public async Task<IActionResult> ImgsFile(IFormFile file)
        {
            string path="wwwroot/imgs/"+file.FileName;
            using (FileStream fs=new FileStream(path,FileMode.OpenOrCreate))
            {
                file.CopyTo(fs);
            }
            return Ok(file.FileName);
        }
      
    }
}
